import Cookies from "js-cookie"

const mutations = {
    // 登录 记录token值
    saveToken(state,payload){
        // 记录token值
        state.token = payload
        // 把token值记录到本地存储中
        localStorage.setItem('token',state.token)
        // 把token值记录在cookie中
        Cookies.set('token', state.token, { expires: 1 })
       
    },


    // 退出 移除token值
    loginOut(state){
        // console.log("点击成功")
        state.token = null
        localStorage.removeItem('token')
        Cookies.remove('token')
    },

    // 用于获取用户详情
    saveUserInfo(state,payload){
        state.userInfo = payload
        localStorage.setItem('userInfo',JSON.stringify(payload))
    }
}

export default mutations